/*
 * Copyright (c) 2001, 2002 Boris Pruessmann and others. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Common Public License v0.5 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors: Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.perforce.api;

import java.util.Map;

/**
 * @version $Revision: 488 $
 * @author <a href="mailto:bpruessmann@users.sourceforge.net>Boris
 *         Pruessmann</a>
 */
public interface IClientUserDelegate {

  /**
   * Provides data to 'p4 command -i'
   * 
   * @param error to be filled in case of an error.
   * @return the provided data.
   */
  String inputData(IError error);

  /**
   * Output error data as a result of a failed operation.
   * 
   * @param errorString the error as String.
   */
  void outputError(String errorString);

  /**
   * Output tabular data as a result of most commands that report metadata.
   * 
   * @param level the level of information; 0 being the default.
   * @param infoString the information string.
   */
  void outputInfo(char level, String infoString);

  /**
   * Output binary data, generally the result of 'p4 print binary_file'.
   * 
   * @param data binary data.
   */
  void outputBinary(byte[] data);

  /**
   * Output text data, generally the result of 'p4 print text_file'.
   * 
   * @param data text data.
   */
  void outputText(byte[] data);

  /**
   * Output tabular data in form of a Map. See p4api.txt for supported
   * operations.
   * 
   * @param data Map containing the data.
   */
  void outputStat(Map<String, ?> data);

  /**
   * Process error data as result of a failed operation.
   * 
   * @param error the Error instance containing details.
   * @return true indicates that we handled the error, false means that handling
   *         should be delegated to ClientUser.handleError.
   */
  boolean handleError(IError error);

  /**
   * Output error in tabular data. This is the 2002.1 replacement for
   * OutputError/OutputInfo. This is not currently used.
   * 
   * @param error object containing the neccessary information.
   * @return true indicates that we handled the message, false means that
   *         handling should be delegated to ClientUser.message.
   */
  boolean message(IError error);

  /** Called when client call is finished. */
  void finished();
}
